package main

import (
	"fmt"
	"net/http"
)

func Ping(w http.ResponseWriter, r *http.Request) {
	fmt.Println("method:", r.Method)
	fmt.Println("url:", r.URL)
	w.Write([]byte("pong"))
}

func Hello(w http.ResponseWriter, r *http.Request) {
	w.Write([]byte("hello, yekai"))
}

func main() {
	//设置路由规则 url:/ping method:get/post, function:handle
	http.HandleFunc("/ping", Ping)
	http.HandleFunc("/hello", Hello)
	//启动http服务器
	http.ListenAndServe(":8080", nil)
}
